<style>
    .searchbox{
        height: 40px;
        width: 100%;
        line-height: 34px;
    }
    .searchbox > *{
        float: left;
    }
    .searchbox label{
        margin-right:3px ;
    }
    .searchbox input[type='text']{
        margin-right: 10px;
        height: 32px;
        padding-left: 4px;
        box-sizing: inherit;
    }
</style>
<div class="layui-breadcrumb-box" >
   <span class="layui-breadcrumb">
        <span>当前位置: </span>
        <a href="#">系统管理 ></a>
        <a><cite>登录日志</cite></a>
    </span>
</div>
<form class="layui-form" style="margin-top: 7px" action="${basePath}system/logs/login" type="0" method="post" name="logsForm" id="logsForm">
    <div class="searchbox" id="searchbox">
        <input type="text" id="username" name="username" placeholder="输入用户名" value="${pd.userName}">
        <input type="text" id="Month" name="Month" value="${pd.mintime}" lay-verify="title" autocomplete="off"
               readonly     placeholder="请选择起始日期" class="layui-input" style="
    width: auto;
">
        <span style="margin-right: 10px">到</span>
        <input type="text" id="Month1" name="Month1" value="${pd.maxtime}" lay-verify="title" autocomplete="off"
               readonly   placeholder="请选择结束日期" class="layui-input" style="width: auto;">
        <input type="button" value="查询" onclick="searchs();" class="layui-btn layui-btn-red"/>
        <input type="button" value="重置查询条件" onclick="goto();" class="layui-btn layui-btn-red"/>
        <@shiro.hasPermission name="denglurizhixiazai">
        <input type="button" value="下载当前日志" onclick="downloadlog();" class="layui-btn layui-btn-red"/>
        </@shiro.hasPermission>
    </div>
        <table id="simple-table" class="layui-table">
            <thead>
            <tr>
                <th>序号</th>
                <th>登录用户</th>
                <th>登录IP</th>
                <th>登录时间</th>
            </tr>
            </thead>
            <tbody>
            <#list Logslist?if_exists as var >
                <tr>
                    <td>${var_index?if_exists+1}</td>
                    <td>${var.userName}</td>
                    <td>${var.userIp}</td>
                    <td>${var.logDate?string('yyyy-MM-dd HH:mm:ss')}</td>
                </tr>

            </#list>
            </tbody>
        </table>
    <#include "/common/page.html" />
</form>
<script>
    var rooturl = "${basePath}system/logs/login";
    var form;
    layui.use(['form', 'layedit', 'laydate'], function () {
        var laydate = layui.laydate;
        form = layui.form;
        $form = $('form');
        laydate.render({
            elem: '#Month1', //指定元素
            type: 'date',
//            theme: '#dd5e6e',
            max:0,
        });
        laydate.render({
            elem: '#Month',  //指定元素
            type: 'date',
//            theme: '#dd5e6e',
            max:0,
            btns: ['clear', 'confirm']
        });
        form.render();
    });
    //检 索
    function searchs() {
        var statiem = $("#Month").val();
        var endtime = $("#Month1").val();
        statiem = statiem.replace("-","/");//替换字符，变成标准格式
        endtime = endtime.replace("-","/");//替换字符，变成标准格式
        var sta = new Date(Date.parse(statiem));
        var end = new Date(Date.parse(endtime));
        if(sta>end){
            layer.alert("起始时间不能大于结束时间！");
            return;
        }
    }
    function goto() {
        reLoadPage("${basePath}system/logs/login");
    }
    function downloadlog() {
        var statiem = $("#Month").val();
        var endtime = $("#Month1").val();
        statiem = statiem.replace("-","/");//替换字符，变成标准格式
        endtime = endtime.replace("-","/");//替换字符，变成标准格式
        var sta = new Date(Date.parse(statiem));
        var end = new Date(Date.parse(endtime));
        if(sta>end){
            layer.alert("起始时间不能大于结束时间！");
            return;
        }
        window.location.href="${basePath}system/logs/Downlogin?userName="+$("#username").val()+"&mintime="
                +$("#Month").val()+"&maxtime="+$("#Month1").val();

    }
</script>
